<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script type="text/javascript" src="${pageContext.request.contextPath}/static/lib/md5/md5.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/static/lib/aes/aes.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/static/lib/aes/pad-zeropadding-min.js"></script>
<script type="text/javascript">
	function checkForm() {
		var pwd = document.getElementById('pwd');
		var password = md5(pwd.value);
		var key = document.getElementById('temporaryKey').value;
		
		password = encrypt(password, key, key);
		
		pwd.value = password;
		
	}
	
	function encrypt(data,key,iv) {
    	var key1  = CryptoJS.enc.Latin1.parse(key);
        var iv1   = CryptoJS.enc.Latin1.parse(iv);
        return CryptoJS.AES.encrypt(data, key1, {iv:iv1,mode:CryptoJS.mode.CBC,padding:CryptoJS.pad.ZeroPadding}).toString();
    }
</script>
<title>Login</title>
</head>
<body>
<input type="hidden" id="temporaryKey" value="${temporaryKey}" />
<form action="${pageContext.request.contextPath}/login.html" method="post" onsubmit="return checkForm()">
	Username:<input type="text" name="username" /><br/>
	Password:<input id="pwd" type="password" name="password" /><br/>
	记住我<input type="checkbox" name="remeberMe" value="1" /><br/>
	<input type="submit" value="Submit"/>
</form>
</body>
</html>